<?php
namespace Mobile\Controller;

use Common\Controller\UserBaseController;

/**
 * 首页控制器
 */
class LastsController extends UserBaseController
{
    /**
     * 首页
     */
    public function lasts()
    {

        header('Content-type:text/json');
        $data   = array();
        $c_type = $_GET['lottery'];
        // $c_time=$_GET['_'];
        switch ($c_type) {
            //幸运飞艇
            case 'XYFT': //幸运飞艇 彩种id 5
                $condition['c_id'] = 5;

                break;
            //北京PK10
            case 'BJPK10': //北京PK10 彩种id 4
                $condition['c_id'] = 4;
                break;
            //重庆时时彩
            case 'CQSSC': //重庆时时彩 彩种id 1
                $condition['c_id'] = 1;
                break;
            //新疆时时彩
            case 'XJSSC': //新疆时时彩 彩种id 2
                $condition['c_id'] = 2;
                break;
            //天津时时彩
            case 'TJSSC': //天津时时彩 彩种id 3
                $condition['c_id'] = 3;
                break;
            //重庆幸运农场
            case 'XYNC': //重庆幸运农场 彩种id 8
                $condition['c_id'] = 8;
                break;
            //广东快乐十分
            case 'GDKLSF': //广东快乐十分 彩种id 6

                $condition['c_id'] = 6;
                break;
            //广西快三
            case 'GXK3': //广西快三 彩种id 7
                $condition['c_id'] = 7;
                break;
            //PC蛋蛋
            case 'PCEGG': //PC蛋蛋 彩种id 11
                $condition['c_id'] = 11;
                break;
            //北京快8
            case 'BJKL8': //北京快8 彩种id 9

                $condition['c_id'] = 9;

                break;
            //广西快乐十分
            case 'GXKLSF': //广西快乐十分 彩种id 10

                $condition['c_id'] = 10;

                break;
            //分分彩
            case 'FFC': //分分彩 彩种id 13
                $condition['c_id'] = 13;
                break;

            default:
                break;
        }
        $time = time() - 5 * 60;
        //$time=strtotime($day);
        // print_r($day);exit;
        $condition['add_time'] = array(array('gt', $time));
        $condition['m_id']     = $_SESSION['member_id'];
        $maxc_no               = M('lottery_order')->where($condition)->max('c_no');
        $condition['c_no']     = $maxc_no;
        $order                 = M('lottery_order')->where($condition)->order('c_no desc,add_time desc')->select();
        // echo M('lottery_order')->getlastSql();exit;
        foreach ($order as $k => $v) {
            $data[$k]['id'] = $v['order_sn'];
            $data[$k]['t']  = $v['w_name'] . ' ' . $v['t_name'];
            $data[$k]['o']  = $v['odds'];
            $data[$k]['a']  = $v['money'];
        }

        echo json_encode($data);exit(0);
    }

}
